package cn.sundat.web.action;

import java.util.List;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletResponse;

import org.apache.struts2.ServletActionContext;

import com.opensymphony.xwork2.ActionContext;
import com.opensymphony.xwork2.ActionSupport;
import com.opensymphony.xwork2.ModelDriven;
import com.opensymphony.xwork2.util.ValueStack;

import cn.sundat.model.Category;
import cn.sundat.service.CategoryService;
import cn.sundat.utils.FastJsonUtil;

public class CategoryAction extends ActionSupport implements ModelDriven<Category>{

	private static final long serialVersionUID = 2761975694372458803L;
	
	@Resource(name="categoryService")
	private CategoryService categoryService;
	
	private Category category = new Category();
	
	public Category getModel() {
		return category;
	}
	
	
	/**
	 * 导航条的查询，查询了前十条
	 * @return
	 */
	public String find() {
		List<Category>  clist = categoryService.findCategoryAll();
		String jsonString = FastJsonUtil.toJSONString(clist);
		HttpServletResponse response = ServletActionContext.getResponse();
		FastJsonUtil.write_json(response, jsonString);
		return NONE;
	}
}
